﻿var canSelFstCategories = new Array();
var $;
_bx.push([function() {
    $ = jQuery;
    $("#categorySearch-keywords").keydown(function(b) {
        var a = window.event ? b.keyCode: b.which;
        if (a == "13" || a.toString() == "13") {
            searchCategory();
            return false;
        }
    });
    $("#categorySearch-submit").click(function() {
        searchCategory();
        return false;
    });
    $("#categoryItem").show();
}]);
_bx.push(["/media/js/jquery-ui-1.8.7.custom.min__39082__.js",
function() {
    $ = jQuery;
    $(".tag").live("change",
    function() {
        changeTag($(this));
    });
    $(".selectData").live("click",
    function() {
        $this = $(this);
        $("#display" + $this.attr("key")).focus();
    });
    var a;
    $(".selectData a").live("click",
    function() {
        $this = $(this);
        var d = $this.attr("key");
        var c = $this.text();
        var e = $this.attr("value");
        if (e == "usedCategory") {
            return;
        }
        if (d == "category_secondCategory" && typeof(_icq.push) == "function") {
            _icq.push("fabu_category_cnt_" + e + "_" + jQuery("input[name=postToken]").attr("value"));
        }
        $("a.selected").removeClass("selected");
        $this.addClass("selected");
        $("#display" + d).val(c).blur();
        selectTag($(this), false, true);
        var b = $("#value" + d);
        b.val(e).blur();
        clearTimeout(a);
        changeTag(b);
        return false;
    });
    $(".selectBox").live("change",
    function() {
        var d = $(this);
        var c = d.attr("key");
        var b = $("#value" + c);
        b.val(d.val());
        d.parents(".controls").find(".selectBox").css("color", "#333");
        if (!d.attr("readonly")) {
            clearTimeout(a);
            if (b.val()) {
                a = setTimeout('changeTag($("#value' + c + '"));', 500);
            }
        }
    }).live("keydown",
    function(g) {
        var f = $("#data" + $(this).attr("key"));
        if (f.is(":visible")) {
            $(this).autocomplete("disable");
            var d = $.ui.keyCode;
            var f = $("#data" + $(this).attr("key"));
            var c = f.find("a.hover").first();
            switch (g.keyCode) {
            case d.UP:
                if (c.length) {
                    c.removeClass("hover");
                    var h = null;
                    f.find("a").each(function() {
                        if ($(this).attr("id") == c.attr("id")) {
                            if (h) {
                                h.addClass("hover");
                            }
                            return false;
                        }
                        h = $(this);
                    });
                } else {
                    f.find("a").last().addClass("hover");
                }
                return;
            case d.DOWN:
                if (c.length) {
                    c.removeClass("hover");
                    var b = false;
                    f.find("a").each(function() {
                        if (b) {
                            $(this).addClass("hover");
                            return false;
                        }
                        if ($(this).attr("id") == c.attr("id")) {
                            b = true;
                        }
                    });
                } else {
                    f.find("a").first().addClass("hover");
                }
                return;
            case d.ESCAPE:
                selectTag($(this), false);
                return;
            case d.ENTER:
            case d.NUMPAD_ENTER:
                c.click();
                return false;
            }
        }
        if ($(this).hasClass("form-input")) {
            selectTag($(this), false, true);
            $(this).autocomplete("enable");
        }
    }).live("focus",
    function() {
        clearTimeout(a);
        var c = $(this);
        c.parents(".controls").find(".selectBox").css("color", "#999");
        c.css("color", "#000");
        if (c.hasClass("selectStyle") || c.val() == "") {
            selectTag(c, true);
        }
        if (!c.attr("readonly")) {
            var b = "/ajax/tag/autocomplete/?category=" + secondCategoryEnglishName + "&cityEnglishName=" + cityEnglishName + "&key=" + encodeURIComponent(c.attr("key"));
            $(".tag").each(function() {
                var e = $(this);
                var d = e.val();
                if (d && d != "其他") {
                    b += "&" + encodeURIComponent(e.attr("name")) + "=" + encodeURIComponent(d);
                }
            });
            $(this).autocomplete("option", "source", b);
        }
    }).live("click",
    function() {
        clearTimeout(a);
        selectTag($(this), true);
    }).live("blur",
    function() {
        var d = $(this);
        setTimeout('$("#' + d.attr("id") + '").autocomplete("close");', 300);
        selectTag(d, false);
        var c = d.attr("key");
        var b = $("#value" + c);
        if (!b.val()) {
            checkAutoComplete(d);
        }
        d.parents(".controls").find(".selectBox").css("color", "#333");
    });
    $("input, select, radio").live("blur",
    function() {
        generateTitle($(this));
    });
    $("input[type=checkbox]").live("change",
    function() {
        generateTitle($(this));
    });
    $(".selectData").live("mouseenter",
    function() {
        isOnSelect = true;
    }).live("mouseleave",
    function() {
        isOnSelect = false;
    });
}]);
function checkAutoComplete(c) {
    $widget = c.autocomplete("widget");
    if ($widget[0].tagName.toLowerCase() == "ul") {
        var b = c.val().toLowerCase();
        var a = [];
        $widget.find("a").each(function() {
            var e = $(this).text().toLowerCase();
            var d = new RegExp("(^|\\s)" + b + "($|\\s)");
            if (e == b || d.exec(e)) {
                a.push($(this));
            }
        });
        if (a.length == 1) {
            a[0].mouseover().click();
        }
    }
}
var autoCompelteOn = false;
function openAutoComplete() {
    selectTag($(this), false);
    var b = $("ul.ui-autocomplete");
    var a = $(".tag_overlay");
    autoCompelteOn = true;
    setTimeout(function() {
        a.show().offset(b.offset()).width(b.width() + 15).height(b.height() + 15);
    },
    10);
}
function closeAutoComplete() {
    $(".tag_overlay").hide();
    autoCompelteOn = false;
}
function selectAutoComplete(f, d) {
    var b = $(this).attr("key");
    var a = $("#value" + b);
    var c = d.item.data[b.split("_")[0]];
    if (c) {
        a.attr("name", b.split("_")[0]);
        a.val(c.id);
        changeTag(a);
    }
}
function changeTag(e) {
    var a = "/ajax/tag/select/?category=" + secondCategoryEnglishName + "&cityEnglishName=" + cityEnglishName;
    var d = e.val();
    var b = e.attr("name");
    a += "&key=" + encodeURIComponent(b) + "&value=" + encodeURIComponent(d);
    var c = "";
    $(".tag").each(function() {
        var g = $(this);
        var f = g.val();
        if (f && f != "其他") {
            c += "&" + encodeURIComponent(g.attr("name")) + "=" + encodeURIComponent(f);
        }
    });
    $.getJSON(a + c,
    function(g) {
        for (type in g) {
            try {
                if (type == "attributes") {
                    for (b in g[type]) {
                        setAttributeValue(b, g[type][b]);
                    }
                } else {
                    $controlBox = $("#meta" + type);
                    $controlBox.html(g[type]);
                }
            } catch(f) {}
        }
    });
}
function getAttributeValue(a) {
    $control = $('*[name="' + a + '"], *[name="' + a + '[]"], *[name="' + a + 'Select"]');
    if (!$control.length) {
        return "";
    }
    var b = "";
    if ($control[0].type.toLowerCase() == "radio...bx.push([" / media / js / swfupload_beta / swfupload__33011__.js ",function(){function a(){return secondCategoryEnglishName=="riyongpin ";}var b=jQuery.browser.msie?Math.ceil(Math.random()*100)%100:"1 ";var l=function(r){return jQuery("#thumb_ "+r.id);};var q=function(){jQuery("#imagesUl ").show();};var h=function(){this.customSettings.loadingTimeout=setTimeout(function(){failOver();},10*1000);};var f=function(){if(jsClicked){jQuery("#uploader ").remove();return;}clearTimeout(this.customSettings.loadingTimeout);jQuery("#jsupload ").hide().html("");jQuery("#uploader ").css("position ","static ").css("top ","0 ");q();jQuery("#uploader small ").fadeIn();jQuery("#imgupload.tipMsg ").html('<span style="color: green ">最多可上传'+imageLimit+"张照片，每张照片不超过10M < /span>").show();};var k=function(){failOver();};var m=function(){jQuery("#imgupload .tipMsg").html("");this.setUploadURL(a()?"http:/ / v0.api.upyun.com / "+img_space+" / ":"http: //www.baixing.com/image_upload/?s");if(a()){this.setPostParams({policy:img_policy,signature:img_signature});}};var j=function(r,s){if(s>0){if(this.support.imageResize){this.startResizedUpload(this.getFile(0).ID,this.customSettings.thumbnail_width,this.customSettings.thumbnail_height,SWFUpload.RESIZE_ENCODING.JPEG,this.customSettings.thumbnail_quality,false);}else{this.startUpload();}}};var o=function(r){if(jQuery("#imagesUl li").length>=imageLimit){jQuery("#imgupload .tipMsg").html('<span style="color:red">非常抱歉！最多只能上传'+imageLimit+"张照片</span>").show();return;}jQuery("#imagesUl").append(jQuery('<li><img title="点击设为封面" id="thumb_'+r.id+'" src="http://static.baixing.net/images/css/global/img_loader.gif" width="64" height="64" class="imgBorderBeta" />\n <span class="imgBeta">正在上传</span><div class="tips hide"><div class="tips-text">点击设为封面</div></div></li>'));imageUploading++;};var n=function(r,t,s){jQuery("#imgupload .tipMsg").html('<span style="color:red">非常抱歉！最多只能上传'+imageLimit+"张照片，每张照片不超过10M</span>").show();};var c=function(s){swfuTimer=new Date().getTime();var r=l(s);r.attr("src","http://static.baixing.net/images/css/global/img_loader.gif").next().html('<a href="javascript:void(0)" onclick="cancelUpload(\''+s.id+"', this)\">取消</a>");};var d=function(s,u){var t=Math.ceil((u/s.size)*100);var r=l(s);r.find(".number").val(t<100?t+"%":"处理中…");};var g=function(u,t){var s=jQuery.parseJSON(t);if(!s){p(u,101,"Result is null");return false;}swfuTimer=new Date().getTime()-swfuTimer;if(swfuTimer>=30000||swfuTimer<=0||Math.floor(Math.random()*10)==0){_gaq.push(["_trackEvent","ImgUpload"+(swfuTimer<30000&&swfuTimer>0?"":"Fail"),"SWF",a()?"UPYUN":"SELF",swfuTimer]);}d(u,u.size);var r=l(u);r.attr("src",a()?"http://img"+(s.url.charCodeAt(1)%3+4)+".baixing.net"+s.url+"_sq":s.url.replace(/\.(\w+)$/,"_sq.$1")).addClass("uploaded").next().attr("title","点击删除这张照片").html('<img width="10" height="8" src="http://static.baixing.net/images/post/dui.gif" align="absmiddle" /> 成功 \n <a href="javascript:void(0)" onclick="cancelUpload(\''+u.id+'\', this)">\n <img src="http://static.baixing.net/images/post/laji.gif" align="absmiddle" width="10" height="10" alt="删除这张图片" border="0"/>\n </a>').parent().prepend('<input type="hidden" name="image[]" value="'+s.url+'" />');imageUploading--;$(".container").length&&$(".container").height("auto");};var e=function(r){if(this.getStats().files_queued>0){if(this.support.imageResize){this.startResizedUpload(this.getFile(0).ID,this.customSettings.thumbnail_width,this.customSettings.thumbnail_height,SWFUpload.RESIZE_ENCODING.JPEG,this.customSettings.thumbnail_quality,false);}else{this.startUpload();}}else{_bx.push(function(){jQuery("#imagesUl li").hover(function(){$(this).find(".tips").show();},function(){$(this).find(".tips").hide();});});}};var p=function(r,t,s){imageUploading--;};SWFUpload.onload=function(){var r={flash_url:"http://static.baixing.net/media/js/swfupload_beta/swfupload__27511__.swf?v="+b,flash9_url:"http://static.baixing.net/media/js/swfupload_beta/swfupload_fp9__27511__.swf?v="+b,upload_url:"http://www.baixing.com/image_upload/?s",custom_settings:{thumbnail_height:800,thumbnail_width:800,thumbnail_quality:75},prevent_swf_caching:false,file_post_name:"file",file_size_limit:"10 MB",file_types:"*.jpg;*.jpeg;*.png;*.gif",file_types_description:"Web Image Files",file_upload_limit:0,button_image_url:"http://static.baixing.net/media/js/swfupload_beta/btn_bg.v2.png",button_placeholder_id:"placeholder",button_width:230,button_height:25,button_window_mode:SWFUpload.WINDOW_MODE.TRANSPARENT,button_cursor:SWFUpload.CURSOR.HAND,swfupload_loaded_handler:f,file_queued_handler:o,file_queue_error_handler:n,file_dialog_start_handler:m,file_dialog_complete_handler:j,upload_start_handler:c,upload_progress_handler:d,upload_error_handler:p,upload_success_handler:g,upload_complete_handler:e,swfupload_preload_handler:h,swfupload_load_failed_handler:k,debug:false};swfu=new SWFUpload(r);};swfobject.addDomLoadEvent(function(){if(typeof(SWFUpload.onload)==="function"&&swfupload){SWFUpload.onload.call(window);}});}]);
    